package com.dmgis.qxfw.dataservice.businessservice.yyhb.controller;

import com.dmgis.qxfw.dataservice.businessservice.api.domain.DbConfig;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.qx.heavy_forecast;
import com.dmgis.qxfw.dataservice.businessservice.common.pojo.*;
import com.dmgis.qxfw.dataservice.businessservice.common.util.DateTime;
import com.dmgis.qxfw.dataservice.businessservice.common.util.FileUtil;
import com.dmgis.qxfw.dataservice.businessservice.common.util.StringUtil;
import com.dmgis.qxfw.dataservice.businessservice.dmgis_mongodb_srv.dataservice.service.Impl.FileRequestService;
import com.dmgis.qxfw.dataservice.businessservice.dmgis_mongodb_srv.dataservice.service.Impl.MongoService1;
import com.dmgis.qxfw.dataservice.businessservice.yyhb.service.EnvirForecastServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("/xthb")
public class EnvirForecastController {
	private  final String operatingSystem;

	@Autowired
	public EnvirForecastController(String operatingSystem) {
		this.operatingSystem = operatingSystem;
	}

	@Autowired
	private EnvirForecastServiceI impl;

	//MongoService1 mongoService=new MongoService1();
	FileRequestService mongoService = new FileRequestService();

	/**
	 * 空气污染条件等级预报查询最新时间
	 * @return
	 */
	@RequestMapping("/airPolInitTime")
	@ResponseBody
	public String airPolInitTime() {
		Date dt = impl.airPolInitTime();
		if (dt == null) {
			return "";
		}
		DateTime date = new DateTime(dt);
		return date.toDateString();
	}

	/**
	 * 根据时间查询污染扩散等级预报
	 * @param request
	 * @return
	 */
	@RequestMapping(value = { "/getEnvirForecastDataGrid", "/getEnvirForecastDataGridWX" })
	@ResponseBody
	public Object getEnvirForecastDataGrid(HttpServletRequest request) {
		String startTime = request.getParameter("startTime") + " 00:00:01";
		String endTime = request.getParameter("endTime") + " 23:59:59";
		List<AirPolConForecast> airList = new ArrayList<AirPolConForecast>();
		airList = impl.getEnvirForecastDataGrid(startTime,endTime);
		return airList;
	}



	/**
	 * 查询空气质量回归统计预报最新时间
	 * @return
	 */
	@RequestMapping("/airRegInitTime")
	@ResponseBody
	public String airRegInitTime() {
		Date dt = impl.airRegInitTime();
		if (dt == null) {
			return "";
		}
		DateTime date = new DateTime(dt);
		return date.toDateString();
	}

	/**
	 *要素查询的站点id
	 * @return
	 */
	@RequestMapping("/initStations")
	@ResponseBody
	public Object initStations() {
		Object stations = impl.initStations();
		return stations;
	}

	/**
	 * 查询空气质量回归预报
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = {"/getAirPolRegForecastWX" })
	@ResponseBody
	public Object getAirPolRegForecastWX(HttpServletRequest request) throws Exception {
		String dateTime = request.getParameter("dateTime")+" 00:00:00";
		String element1 = request.getParameter("element");
		String element = "";
		if ("AQI".equals(element1)) {
			element = "AQI";
		}
		if ("PM2.5".equals(element1)) {
			element = "PM2p5";
		} else if ("O₃_8H".equals(element1)) {
			element = "O3_8H";
		} else if ("O₃_1H".equals(element1)) {
			element = "O3_1H";
		} else
			element = "PM10";
		List<AirPolRegForecast> list = impl.getAirPolRegForecast(element, dateTime);
		List<String> hours = new ArrayList<String>();
		List<Double> values = new ArrayList<Double>();
		Map<String, List<Double>> stationValMap = new HashMap<String, List<Double>>();
		for (AirPolRegForecast actualData : list) {

			hours.add(actualData.getObservTime());
			double value = 0d;
			switch (element) {
				case "PM2p5":
					value = actualData.getPM2p5();
					break;
				case "PM10":
					value = actualData.getPM10();
					break;
				case "O3_8H":
					value = actualData.getO3_8H();
					break;
				case "O3_1H":
					value = actualData.getO3_1H();
					break;
				default:
					break;
			}
			values.add(value);
			stationValMap.put(element1, values);
		}
		ArrayList<Object> result = new ArrayList<Object>();
		result.add(hours);
		for (String key : stationValMap.keySet()) {
			ArrayList<Object> tempArr = new ArrayList<Object>();
			tempArr.add(key);
			tempArr.add(stationValMap.get(key));
			result.add(tempArr);
		}
		return result;
	}

	@RequestMapping(value = { "/getAirPolRegForecast"})
	@ResponseBody
	public Object getAirPolRegForecast(HttpServletRequest request) throws Exception {
		String dateTime = request.getParameter("dateTime")+" 00:00:00";
		String element1 = request.getParameter("element");
		String chartType = request.getParameter("ChartType");
		String element = "";
		if ("AQI".equals(element1)) {
			element = "AQI";
		} else if ("PM2.5".equals(element1)) {
			element = "PM2p5";
		} else if ("O₃_8H".equals(element1)) {
			element = "O3_8H";
		} else if ("O₃_1H".equals(element1)) {
			element = "O3_1H";
		} else
			element = "PM10";
		List<AirPolRegForecast> list = impl.getAirPolRegForecast(element, dateTime);

		String xValue = "[";
		String yValue = "[";

		String tableData = "[";
		for (AirPolRegForecast arf : list) {
			Field field = arf.getClass().getField(element);
			xValue += "'" + DateTime.parseDate(arf.getObservTime()).toDateString() + "',";
			yValue += field.get(arf) + ",";
			tableData += "{\"dateChar\":\"" + arf.getObservTime() + "\",\"AQIforecast\":\"" + arf.getAQI()
					+ "\",\"other\":\"" + field.get(arf) + "\"},";
		}
		if (xValue.endsWith(",")) {
			xValue = xValue.substring(0, xValue.length() - 1);
		}
		xValue = xValue + "]";
		if (yValue.endsWith(",")) {
			yValue = yValue.substring(0, yValue.length() - 1);
		}
		yValue = yValue + "]";
		yValue = "[{name:'" + element1 + "',data:" + yValue + "},";
		if (yValue.endsWith(",")) {
			yValue = yValue.substring(0, yValue.length() - 1);
		}
		yValue = yValue + "]";
		if (tableData.endsWith(",")) {
			tableData = tableData.substring(0, tableData.length() - 1);
		}
		tableData = tableData + "]";
		String temp = xValue + "|" + yValue + "|['" + chartType + "']" + "|" + tableData + "|['" + element1 + "']|['"
				+ chartType.trim() + "']";
		return temp;
	}

	/**
	 * 查询首页空气质量预报
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = { "/getZYAirPolRegForecast" })
	@ResponseBody
	public Object getZYAirPolRegForecast(HttpServletRequest request) throws Exception {
		String dateTime = request.getParameter("dateTime");
		List<AirPolRegForecast> list = impl.getZYAirPolRegForecast(dateTime);
		return list;
	}

	/**
	 *  空气质量回归预报检验
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/getAirPolRegForecastCheck")
	@ResponseBody
	public String getAirPolRegForecastCheck(HttpServletRequest request) throws Exception {
		String dateTime = request.getParameter("dateTime1");
		String element1 = request.getParameter("element");

		// 过去30天实况
		String monthAgo = DateTime.parseDate(dateTime).AddDays(-30).toDateString();
		List<AllCityInfo> allList = new ArrayList<AllCityInfo>();
		allList = impl.getAllCityInfo(element1, monthAgo, dateTime, "Qs");
		String agoyValue = "[";
		String agoxValue = "[";
		String agoyValueFore = "[";
		String agoxValueFore = "[";
		for (AllCityInfo aci : allList) {
			DateTime dt = new DateTime(aci.getObservTime());
			Field field = aci.getClass().getField(element1);
			agoxValue += "'" + dt.toDateString() + "',";
			agoyValue += field.get(aci) + ",";
		}
		if (agoxValue.endsWith(",")) {
			agoxValue = agoxValue.substring(0, agoxValue.length() - 1);
		}
		agoxValue = agoxValue + "]";
		if (agoyValue.endsWith(",")) {
			agoyValue = agoyValue.substring(0, agoyValue.length() - 1);
		}
		agoyValue = agoyValue + "]";
		agoyValue = "[{name:'" + element1 + "观测值',data:" + agoyValue + "},";

		// 历史预报值
		List<AirPolRegForecast> foreList = new ArrayList<AirPolRegForecast>();
		foreList = impl.getAgoAirPolRegForecast(element1, monthAgo, dateTime);
		String elements = "";
		if (element1.contains("AQI")) {
			elements = "AQI";
		}
		if (element1.contains("ConcenPM2p5")) {
			elements = "PM2p5";
		}
		if (element1.contains("ConcenPM10")) {
			elements = "PM10";
		}
		if (element1.contains("ConcenO38H")) {
			elements = "O3_8H";
		}
		if (element1.equals("ConcenO3")) {
			elements = "O3_1H";
		}
		for (AirPolRegForecast ap : foreList) {
			Field field = ap.getClass().getField(elements);
			agoxValueFore += "'" + ap.getObservTime() + "',";
			agoyValueFore += field.get(ap) + ",";
		}
		if (agoxValueFore.endsWith(",")) {
			agoxValueFore = agoxValueFore.substring(0, agoxValueFore.length() - 1);
		}
		agoxValueFore = agoxValueFore + "]";
		if (agoyValueFore.endsWith(",")) {
			agoyValueFore = agoyValueFore.substring(0, agoyValueFore.length() - 1);
		}
		agoyValueFore = agoyValueFore + "]";
		agoyValueFore = "{name:'" + element1 + "预测值',data:" + agoyValueFore + "}]";
		String yValue = agoyValue + agoyValueFore;
		String temp = agoxValue + "|" + yValue;
		return temp;
	}

	/**
	 * 空气质量精细化预报初始化时间
	 * @returnaddDayChart
	 */
	@RequestMapping("/makeRefineInit")
	@ResponseBody
	public String makeRefineInit() {
		Date dt = impl.makeRefineInit();
		DateTime date = new DateTime(dt);
		return date.toDateString();
	}

	/**
	 * 查询空气质量精细化预报
	 * @param request
	 * @return
	 */
	@RequestMapping(value = {"/makeRefineForecastWX" })
	@ResponseBody
	public Object makeRefineForecastWX(HttpServletRequest request) throws ParseException {
		String startTime = request.getParameter("StartTime");
		String endTime = request.getParameter("EndTime");
		String type = request.getParameter("InquireType");
		String type1 = "";
		List<AirPolForecast> fList = new ArrayList<AirPolForecast>();
		if ("24小时预报".equals(type.trim())) {
			type1 = "24";
			//int ntimes =168; //Integer.valueOf(queryPoint);
			fList = impl.getAirPolForecast(startTime,endTime, type1);
		} else {
			type1 = "1";
			fList = impl.getAirPolForecast(startTime,endTime, type1);
		}
		for(int i=0;i<fList.size();i++){
			SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd hh时");
			Integer ntimes= fList.get(i).getNtimes();
			Calendar Cal=Calendar.getInstance();
			Cal.setTime(fList.get(i).getDateChar());
			Cal.add(Calendar.HOUR_OF_DAY,ntimes);
			fList.get(i).setTime(simpleDateFormat.format(Cal.getTime()));
		}
		return fList;
	}


	@RequestMapping(value = { "/makeRefineForecast" })
	@ResponseBody
	public String makeRefineForecast(HttpServletRequest request) {
		String dateTime = request.getParameter("dateTime");
		String type = request.getParameter("InquireType");
		String queryPoint = request.getParameter("QueryPoint");
		String type1 = "";
		List<AirPolForecast> fList = new ArrayList<AirPolForecast>();
		if ("24小时预报".equals(type.trim())) {
			type1 = "24";
			fList = impl.getAirPolForecast1(dateTime,type1);
		} else {
			type1 = "24";
			int qp = Integer.valueOf(queryPoint);
			fList = impl.getHourAirPolForecast(dateTime, qp, type1);
		}

		String tableData = "[";
		if ("1".equals(type1)) {
			for (int i = 0; i < fList.size(); i++) {
				DateTime date = new DateTime(fList.get(i).getDateChar());
				tableData += "{\"num\":\"" + i + 1 + "\",\"StationId\":\"" + fList.get(i).getStationID()
						+ "\",\"StationName\":\"" + fList.get(i).getStationName() + "\",\"dateChar\":\""
						+ date.toDateTimeString() + "\",\"PM10\":\"" + fList.get(i).getPM10() + "\",\"O₃_1H\":\""
						+ fList.get(i).getO3_1h() + "\",\"O₃_8H\":\"" + fList.get(i).getO3_8h() + "\",\"PM2.5\":\""
						+ fList.get(i).getPM2_5() + "\",\"AQI\":\"" + fList.get(i).getAQI() + "\",\"pollution\":\""
						+ fList.get(i).getPRI() + "\",\"GRADE\":\"" + fList.get(i).getGRADE() + "\"},";
			}
		} else {
			for (int i = 0; i < fList.size(); i++) {
				DateTime date = new DateTime(fList.get(i).getDateChar());
				tableData += "{\"num\":\"" + i + 1 + "\",\"StationId\":\"" + fList.get(i).getStationID()
						+ "\",\"StationName\":\"" + fList.get(i).getStationName() + "\",\"dateChar\":\""
						+ date.toDateString() + "\",\"PM10\":\"" + fList.get(i).getPM10() + "\",\"O₃_1H\":\""
						+ fList.get(i).getO3_1h() + "\",\"O₃_8H\":\"" + fList.get(i).getO3_8h() + "\",\"PM2.5\":\""
						+ fList.get(i).getPM2_5() + "\",\"SO2\":\"" + fList.get(i).getSO2() + "\",\"NO2\":\""
						+ fList.get(i).getNO2() + "\",\"CO\":\"" + fList.get(i).getCO() + "\",\"AQI\":\""
						+ fList.get(i).getAQI() + "\",\"pollution\":\"" + fList.get(i).getPRI() + "\",\"GRADE\":\""
						+ fList.get(i).getGRADE() + "\"},";
			}
		}
		if (tableData.endsWith(",")) {
			tableData = tableData.substring(0, tableData.length() - 1);
		}
		tableData = tableData + "]";
		String temp = tableData + "|" + "[" + type1 + "]";

		return temp;
	}
	/**
	 * 查询能见度最新时间
	 * @return
	 */
	@RequestMapping("/initVisibilityForecastTime")
	@ResponseBody
	public String initVisibilityForecastTime() {
		Date dt = impl.initVisibilityForecastTime();
		DateTime date = new DateTime(dt);
		return date.toDateString();
	}

	/**
	 * 能见度预报查询
	 * @param request
	 * @return
	 */
	@RequestMapping(value = { "/visibilityForecast", "/visibilityForecastWX" })
	@ResponseBody
	public Object visibilityForecast(HttpServletRequest request) {
		String startTime = request.getParameter("startTime");
		String dateTime = request.getParameter("dateTime");
		String judge = request.getParameter("judge");
		String type = "";
		String ty = request.getParameter("type");
		if (!StringUtil.IsNullOrEmpty(ty)) {
			type = ty.trim();
		}
		String radio = request.getParameter("hourOrDay");
		String stationId = "59015";
		String title = "";
		List<VisibilityForecast> vlist = new ArrayList<VisibilityForecast>();
		if ("时".equals(radio)) {
			if ("1".equals(judge)) {
				vlist = impl.getVisibilityForecast(stationId, startTime, dateTime);
				title = "['" + startTime + "日至" + dateTime + "日的小时能见度预报" + "']";
			} else {
				vlist = impl.getOneDayVisibilityForecast(stationId, startTime, radio);
				title = "['" + startTime + "日的小时能见度预报" + "']";
			}
		} else if ("日".equals(radio)) {
			if ("1".equals(judge)) {
				vlist = impl.getVisibilityForecast(stationId, startTime, dateTime);
				title = "['" + startTime + "日至" + dateTime + "日的日能见度预报" + "']";
			} else {
				vlist = impl.getOneDayVisibilityForecast(stationId, startTime, radio);
				title = "['" + startTime + "日的日能见度预报" + "']";
			}
		}else {
			//app调用
			List<VisibilityForecast> vlist1 = new ArrayList<VisibilityForecast>();
			vlist1 = impl.getVisibilityForecast(stationId, startTime,dateTime);
			List<String> hours = new ArrayList<String>();
			List<Double> values = new ArrayList<Double>();
			Map<String, List<Double>> stationValMap = new HashMap<String, List<Double>>();
			for (VisibilityForecast actualData : vlist1) {
				SimpleDateFormat simpleDateFormat=new SimpleDateFormat("MM-dd HH");
				hours.add(simpleDateFormat.format(actualData.getDateChar()));
				double value = 0d;
				value = actualData.getHazeVisibility();
				values.add(value);
				stationValMap.put("能见度", values);
			}
			ArrayList<Object> result = new ArrayList<Object>();
			result.add(hours);
			for (String key : stationValMap.keySet()) {
				ArrayList<Object> tempArr = new ArrayList<Object>();
				tempArr.add(key);
				tempArr.add(stationValMap.get(key));
				result.add(tempArr);
			}
			return result;
		}
		String xValue = "[";
		String yValue = "[";
		String listData = "[";
		for (VisibilityForecast vf : vlist) {
			DateTime dt = new DateTime(vf.getDateChar());
			if ("时".equals(radio)) {
				xValue += "'" + dt.toDateTimeString("yyyy-MM-dd HH") + "',";
			} else if ("日".equals(radio)) {
				xValue += "'" + dt.toDateTimeString("yyyy-MM-dd") + "',";
			}
			yValue += vf.getHazeVisibility() + ",";
			listData += "{\"date\":\"" + dt.toDateTimeString("yyyy-MM-dd HH") + "\",\"visi\":\""
					+ vf.getHazeVisibility() + "\"},";
		}
		if (xValue.endsWith(",")) {
			xValue = xValue.substring(0, xValue.length() - 1);
		}
		xValue = xValue + "]";
		if (yValue.endsWith(",")) {
			yValue = yValue.substring(0, yValue.length() - 1);
		}
		yValue = yValue + "]";
		yValue = "[{name:'能见度',data:" + yValue + "}]";
		if (listData.endsWith(",")) {
			listData = listData.substring(0, listData.length() - 1);
		}
		listData = listData + "]";
		String temp = xValue + "|" + yValue + "|" + title + "|['" + type + "']|" + listData;
		return temp;
	}



	/**
	 * 霾预报查询最新时间
	 * @return
	 */
	@RequestMapping("/initSmogTime")
	@ResponseBody
	public String initSmogTime() {
		Date dt = impl.initSmogTime();
		DateTime date = new DateTime(dt);
		return date.toDateString();
	}

	/**
	 * 查询霾预报
	 * @param request
	 * @return
	 */
	@RequestMapping("/querySmogFile")
	@ResponseBody
	public List<SmogFile> querySmogFile(HttpServletRequest request) {
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		List<SmogFile> sfList = new ArrayList<SmogFile>();
		sfList = impl.getSmogFile(startTime, endTime);
		for (SmogFile sf : sfList) {
			String serviceFilePath = "";
			// 下载
			String fileName = sf.getFileName();
			String path = request.getContextPath();
			String basePath = DbConfig.IP + path
					+ "/Temp/Smog/";
			String serviceUrl = basePath + fileName;
			String urlpath ;
			if (operatingSystem.equals("Windows")){
				 urlpath = request.getSession().getServletContext().getRealPath("/") + "Temp\\Smog\\";
			}else {
				 urlpath = request.getSession().getServletContext().getRealPath("/") + "Temp/Smog/";
			}

			serviceFilePath = urlpath + fileName;// 服务器文件
			FileUtil.mkDirs(urlpath);// 创建文件夹，生成多级目录
			FileUtil.ClearTempFiles(urlpath, 1000);// 清除缓存
			// 如果目录中不存在文件，下载雷达文件到temp目录
			File serviceFile = new File(serviceFilePath);// 服务器文件
			if (!serviceFile.exists()) {// 把文件上传到服务器
				Map<String, Object> queryMap = new HashMap<String, Object>();
				queryMap.put("filename", sf.getFileName());
//				queryMap.put("advCode", DbConfig.advCode);
				queryMap.put("collectionName", "haze_file");
				byte[] data = mongoService.selectData(queryMap);
				if (data == null) {
					serviceFilePath = "";
				} else {
					FileUtil.bytesToFile(data, serviceFilePath);
				}
			}
			if (!serviceFilePath.equals("")) {
				serviceFilePath = serviceUrl;
			}

			String file = serviceFilePath;
			//添加视频路径
			sf.setFilePath(file);
		}
		return sfList;
	}

	/**
	 * txt下载
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/ReadTxt")
	@ResponseBody
	public String ReadTxt(HttpServletRequest request) throws Exception {
		String filename = request.getParameter("filename");
		String serviceFilePath = "";
		// 下载
		String path = request.getContextPath();
		String basePath = DbConfig.IP + path
				+ "/Temp/Smog/";
		String serviceUrl = basePath + filename;
		String urlpath;
		if (operatingSystem.equals("Windows")){
			 urlpath = request.getSession().getServletContext().getRealPath("/") + "Temp\\Smog\\";
		}else {
			 urlpath = request.getSession().getServletContext().getRealPath("/") + "Temp/Smog/";
		}

		serviceFilePath = urlpath + filename;// 服务器文件
		FileUtil.mkDirs(urlpath);// 创建文件夹，生成多级目录
		FileUtil.ClearTempFiles(urlpath, 1000);// 清除缓存
		// 如果目录中不存在文件，下载雷达文件到temp目录
		File serviceFile = new File(serviceFilePath);// 服务器文件
		if (!serviceFile.exists()) {// 把文件上传到服务器
			Map<String, Object> queryMap = new HashMap<String, Object>();
			queryMap.put("filename", filename);
			queryMap.put("advCode", DbConfig.advCode);
			queryMap.put("collectionName", "haze_file");
			byte[] data = mongoService.selectData(queryMap);
			if (data == null) {
				serviceFilePath = "";
			} else {
				FileUtil.bytesToFile(data, serviceFilePath);
			}
		}
		if (!serviceFilePath.equals("")) {
			serviceFilePath = serviceUrl;
		}

		String file = serviceFilePath;
		//添加路径
		return file;
	}

	/**
	 * 查询重污染天气最新时间
	 * 
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException
	 */
	@RequestMapping("/getheavyFcst")
	@ResponseBody
	public Object getheavyFcst(HttpServletRequest request, Model model) throws ParseException {
		Date dt = impl.getheavyFcst();
		DateTime date = new DateTime(dt);
		return date.toDateTimeString();
	}

	/**
	 * 手动判断重污染天气
	 * 
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException
	 */
	@RequestMapping("/getRGresult")
	@ResponseBody
	public Object getRGresult(HttpServletRequest request, Model model) throws Exception {
		String date = request.getParameter("start_date") + ":00:00";
		String type = request.getParameter("type");
		String result = "";
		List<heavy_forecast> resultList = impl.getRGresult(date, type);
		for (heavy_forecast heavy : resultList) {
			result+=heavy.getJudgetype()+":"+ heavy.getPhenomenon()+" AQI:"+heavy.getAqi()+"|";
		}
		return result;
	}

	/**
	 * 自动判断重污染天气
	 * 
	 * @param request
	 * @param model
	 * @return
	 * @throws ParseException
	 */
	@RequestMapping("/getZDresult")
	@ResponseBody
	public Object getZDresult(HttpServletRequest request, Model model) throws ParseException {
		String date = request.getParameter("date") + ":00:00";
		String type = request.getParameter("type");
		String result = "";
		List<heavy_forecast> resultList = impl.getRGresult(date, type);
		for (heavy_forecast heavy : resultList) {
			result = heavy.getPhenomenon();
		}
		return result;
	}
}
